package com.bysc.userservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bysc.userservice.entity.UserInfoTitle;
import com.bysc.userservice.entity.UserTitle;
import com.bysc.userservice.mapper.UserTitleMapper;
import com.bysc.userservice.service.UserInfoTitleService;
import com.bysc.userservice.service.UserTitleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kkk
 * @since 2024-05-20
 */
@Service
public class UserTitleServiceImpl extends ServiceImpl<UserTitleMapper, UserTitle> implements UserTitleService {
    @Autowired
    private UserTitleService userTitleService;

    @Autowired
    private UserInfoTitleService userInfoTitleService;


    @Override
    public HashMap<String, List> getTitleListById(String userId) {
        List<UserInfoTitle> privateList = userInfoTitleService.list(new QueryWrapper<UserInfoTitle>().eq("user_id", userId));
        List<UserTitle> publicList = userTitleService.list(new QueryWrapper<UserTitle>().eq("is_public", 0));
        HashMap<String, List> map = new HashMap<>();
        map.put("privateList", privateList);
        map.put("publicList", publicList);
        return map;
    }
}
